import random
import string

def generate_strong_password(length=12, include_uppercase=True, include_lowercase=True, include_digits=True, include_symbols=True):
    if length < 4:
        raise ValueError("Password length should be at least 4 to ensure it includes one uppercase letter and one special symbol.")
    
    uppercase_letters = string.ascii_uppercase if include_uppercase else ""
    lowercase_letters = string.ascii_lowercase if include_lowercase else ""
    digits = string.digits if include_digits else ""
    symbols = string.punctuation if include_symbols else ""
    
    # 密码确定为字段
    mandatory_characters = []
    if include_uppercase:
        mandatory_characters.append(random.choice(uppercase_letters))
    if include_symbols:
        mandatory_characters.append(random.choice(symbols))
    
    # 密码设置
    all_characters = uppercase_letters + lowercase_letters + digits + symbols
    if not all_characters:
        raise ValueError("No characters available to generate the password. Please enable at least one character set.")
    
    # 生成密码的其余部分
    remaining_length = length - len(mandatory_characters)
    password_characters = random.choices(all_characters, k=remaining_length)
    
    # 向密码添加必需字符
    password_characters.extend(mandatory_characters)
    
    # 随机排列字符以确保随机顺序
    random.shuffle(password_characters)
    
    # 连接字符以形成最终密码
    password = ''.join(password_characters)
    return password